/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * LayananMasukForm.java
 *
 * Created on Nov 13, 2011, 8:43:54 PM
 */
package Com.TransaksiParkirdanLaporan.Com.Transaksi;

import Com.TransaksiParkirdanLaporan.Com.Laporan.LaporanController;
import Login.LoginController;
import Login.MainForm;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import oracle.net.nt.ConnOption;

/**
 *
 * @author Tea-Nose
 */
public class LayananMasukForm extends javax.swing.JFrame {

    /** Creates new form LayananMasukForm */
    // private int counter = 0;
    public String jamMasukKaryawan;

    public LayananMasukForm(String jamMasukKaryawan) {
        initComponents();

        LaporanController.showDateAndClock(dateLabel);
        this.jamMasukKaryawan = jamMasukKaryawan;
        jamMasukShift.setText(jamMasukKaryawan);

        TransaksiParkirController.noParkir(idParkirTextField);


        try {
            LoginController.showKaryawan(nameUserLabel, nipUserLabel, jabatanLabel);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(LayananMasukForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(LayananMasukForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(LayananMasukForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(LayananMasukForm.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel1 = new javax.swing.JPanel();
        jabatanLabel = new javax.swing.JLabel();
        nipUserLabel = new javax.swing.JLabel();
        nameUserLabel = new javax.swing.JLabel();
        jamMasukShift = new javax.swing.JLabel();
        label_Jam_Masuk = new javax.swing.JLabel();
        logoutButton = new javax.swing.JButton();
        userLabel = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        okButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        merkHelmLabel = new javax.swing.JLabel();
        merkHelmText2 = new javax.swing.JTextField();
        merkHelmText1 = new javax.swing.JTextField();
        merkHelmText = new javax.swing.JTextField();
        jenisHelmLabel = new javax.swing.JLabel();
        jenisHelmCmbBox1 = new javax.swing.JComboBox();
        jenisHelmCmbBox2 = new javax.swing.JComboBox();
        jenisHelmCmbBox3 = new javax.swing.JComboBox();
        jumlahHelmLabel = new javax.swing.JLabel();
        jumlahHelmText = new javax.swing.JTextField();
        noPolisiLabel = new javax.swing.JLabel();
        kodeKaresidenanText = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        noKendaraanText = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        kodeWilayahText = new javax.swing.JTextField();
        idParkirTextField = new javax.swing.JTextField();
        idParkirLabel = new javax.swing.JLabel();
        dateLabel = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        back_Button = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Layanan Masuk Form");
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(37, 232, -1, -1));
        getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 46, 770, 10));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Data Pegawai", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jabatanLabel.setFont(new java.awt.Font("Tahoma", 0, 12));
        jabatanLabel.setText("STAFF PARKIR");
        jPanel1.add(jabatanLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 110, -1, -1));

        nipUserLabel.setFont(new java.awt.Font("Tahoma", 0, 12));
        nipUserLabel.setText("STAFF300");
        jPanel1.add(nipUserLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 90, -1, -1));

        nameUserLabel.setFont(new java.awt.Font("Tahoma", 0, 12));
        nameUserLabel.setText("Baidi");
        jPanel1.add(nameUserLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 70, -1, -1));

        jamMasukShift.setText("12:00:00");
        jPanel1.add(jamMasukShift, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 160, -1, -1));

        label_Jam_Masuk.setText("Jam Masuk");
        jPanel1.add(label_Jam_Masuk, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 140, -1, -1));

        logoutButton.setText("Logout");
        logoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButtonActionPerformed(evt);
            }
        });
        jPanel1.add(logoutButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 330, -1, -1));

        userLabel.setFont(new java.awt.Font("Tahoma", 0, 12));
        userLabel.setText("User: ");
        jPanel1.add(userLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, -1, -1));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 50, 190, 380));

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Transaksi Parkir", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        okButton.setText("Ok");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });
        jPanel2.add(okButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 300, 80, 40));

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });
        jPanel2.add(cancelButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 300, 80, 40));

        merkHelmLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        merkHelmLabel.setText("Merk Helm");
        jPanel2.add(merkHelmLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 220, -1, -1));

        merkHelmText2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        merkHelmText2.setEnabled(false);
        merkHelmText2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                merkHelmText2ActionPerformed(evt);
            }
        });
        jPanel2.add(merkHelmText2, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 220, 60, 40));

        merkHelmText1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        merkHelmText1.setEnabled(false);
        merkHelmText1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                merkHelmText1ActionPerformed(evt);
            }
        });
        jPanel2.add(merkHelmText1, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 220, 60, 40));

        merkHelmText.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        merkHelmText.setEnabled(false);
        merkHelmText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                merkHelmTextActionPerformed(evt);
            }
        });
        jPanel2.add(merkHelmText, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 220, 60, 40));

        jenisHelmLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        jenisHelmLabel.setText("Jenis Helm");
        jPanel2.add(jenisHelmLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 180, -1, -1));

        jenisHelmCmbBox1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jenisHelmCmbBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "FF", "HF" }));
        jenisHelmCmbBox1.setEnabled(false);
        jenisHelmCmbBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jenisHelmCmbBox1ActionPerformed(evt);
            }
        });
        jPanel2.add(jenisHelmCmbBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 180, -1, 30));

        jenisHelmCmbBox2.setFont(new java.awt.Font("Tahoma", 0, 14));
        jenisHelmCmbBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "FF", "HF" }));
        jenisHelmCmbBox2.setEnabled(false);
        jPanel2.add(jenisHelmCmbBox2, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 180, -1, 30));

        jenisHelmCmbBox3.setFont(new java.awt.Font("Tahoma", 0, 14));
        jenisHelmCmbBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "FF", "HF" }));
        jenisHelmCmbBox3.setEnabled(false);
        jenisHelmCmbBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jenisHelmCmbBox3ActionPerformed(evt);
            }
        });
        jPanel2.add(jenisHelmCmbBox3, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 180, 43, 30));

        jumlahHelmLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        jumlahHelmLabel.setText("Jumlah Helm");
        jPanel2.add(jumlahHelmLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 140, -1, -1));

        jumlahHelmText.setToolTipText("Jumlah helm hanya bisa diisi dengan angka 0-3");
        jumlahHelmText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jumlahHelmTextActionPerformed(evt);
            }
        });
        jumlahHelmText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jumlahHelmTextKeyReleased(evt);
            }
        });
        jPanel2.add(jumlahHelmText, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 140, 60, 30));

        noPolisiLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        noPolisiLabel.setText("No. Polisi");
        jPanel2.add(noPolisiLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 100, 100, -1));

        kodeKaresidenanText.setFont(new java.awt.Font("Tahoma", 0, 14));
        kodeKaresidenanText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kodeKaresidenanTextActionPerformed(evt);
            }
        });
        kodeKaresidenanText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                kodeKaresidenanTextKeyReleased(evt);
            }
        });
        jPanel2.add(kodeKaresidenanText, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 100, 30, 30));

        jLabel5.setText("-");
        jPanel2.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 110, -1, -1));

        noKendaraanText.setFont(new java.awt.Font("Tahoma", 0, 14));
        noKendaraanText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                noKendaraanTextActionPerformed(evt);
            }
        });
        noKendaraanText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                noKendaraanTextKeyReleased(evt);
            }
        });
        jPanel2.add(noKendaraanText, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 100, 50, 30));

        jLabel6.setText("-");
        jPanel2.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 110, -1, -1));

        kodeWilayahText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                kodeWilayahTextKeyReleased(evt);
            }
        });
        jPanel2.add(kodeWilayahText, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 100, 40, 30));

        idParkirTextField.setEditable(false);
        jPanel2.add(idParkirTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 60, 90, 30));

        idParkirLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        idParkirLabel.setText("No. Parkir");
        jPanel2.add(idParkirLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 60, 100, -1));

        dateLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
        dateLabel.setText("Date/Time ");
        jPanel2.add(dateLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 20, 220, -1));

        getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 50, 580, 380));

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        back_Button.setText("Back");
        back_Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                back_ButtonActionPerformed(evt);
            }
        });
        jPanel3.add(back_Button, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, -1, -1));

        jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 36));
        jLabel3.setText("Pelayanan Kendaraan Masuk");
        jPanel3.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 0, -1, -1));

        getContentPane().add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 770, 50));
        setJMenuBar(jMenuBar1);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-775)/2, (screenSize.height-458)/2, 775, 458);
    }// </editor-fold>//GEN-END:initComponents

    private void kodeKaresidenanTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kodeKaresidenanTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_kodeKaresidenanTextActionPerformed

    private void noKendaraanTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_noKendaraanTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_noKendaraanTextActionPerformed

    private void jenisHelmCmbBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jenisHelmCmbBox1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jenisHelmCmbBox1ActionPerformed

    private void merkHelmTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_merkHelmTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_merkHelmTextActionPerformed

    private void jumlahHelmTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jumlahHelmTextActionPerformed
        // TODO add your handling code here:
        if (jumlahHelmText.getText().matches("[0123]")) {
            if (Integer.parseInt(jumlahHelmText.getText()) == 1) {
                jenisHelmCmbBox1.setEnabled(true);
                merkHelmText2.setEnabled(true);
            } else if (Integer.parseInt(jumlahHelmText.getText()) == 2) {
                jenisHelmCmbBox1.setEnabled(true);
                jenisHelmCmbBox2.setEnabled(true);
                merkHelmText2.setEnabled(true);
                merkHelmText1.setEnabled(true);
            } else if (Integer.parseInt(jumlahHelmText.getText()) == 3) {
                jenisHelmCmbBox1.setEnabled(true);
                jenisHelmCmbBox2.setEnabled(true);
                jenisHelmCmbBox3.setEnabled(true);
                merkHelmText2.setEnabled(true);
                merkHelmText1.setEnabled(true);
                merkHelmText.setEnabled(true);
            }
        }
    }//GEN-LAST:event_jumlahHelmTextActionPerformed

    private void merkHelmText1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_merkHelmText1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_merkHelmText1ActionPerformed

    private void merkHelmText2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_merkHelmText2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_merkHelmText2ActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        // TODO add your handling code here:
        jenisHelmCmbBox1.setEnabled(false);
        jenisHelmCmbBox2.setEnabled(false);
        jenisHelmCmbBox3.setEnabled(false);
        merkHelmText2.setEnabled(false);
        merkHelmText1.setEnabled(false);
        merkHelmText.setEnabled(false);
        jumlahHelmText.setText(null);
        kodeKaresidenanText.setText(null);
        kodeWilayahText.setText(null);
        noKendaraanText.setText(null);
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void jumlahHelmTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jumlahHelmTextKeyReleased
        // TODO add your handling code here:
        if (jumlahHelmText.getText().matches("1")) {
            jenisHelmCmbBox1.setEnabled(false);
            jenisHelmCmbBox2.setEnabled(false);
            jenisHelmCmbBox3.setEnabled(false);
            merkHelmText2.setEnabled(false);
            merkHelmText1.setEnabled(false);
            merkHelmText.setEnabled(false);
            jenisHelmCmbBox1.setEnabled(true);
            merkHelmText2.setEnabled(true);
        } else if (jumlahHelmText.getText().matches("2")) {
            jenisHelmCmbBox1.setEnabled(false);
            jenisHelmCmbBox2.setEnabled(false);
            jenisHelmCmbBox3.setEnabled(false);
            merkHelmText2.setEnabled(false);
            merkHelmText1.setEnabled(false);
            merkHelmText.setEnabled(false);
            jenisHelmCmbBox1.setEnabled(true);
            jenisHelmCmbBox2.setEnabled(true);
            merkHelmText2.setEnabled(true);
            merkHelmText1.setEnabled(true);
        } else if (jumlahHelmText.getText().matches("3")) {
            jenisHelmCmbBox1.setEnabled(false);
            jenisHelmCmbBox2.setEnabled(false);
            jenisHelmCmbBox3.setEnabled(false);
            merkHelmText2.setEnabled(false);
            merkHelmText1.setEnabled(false);
            merkHelmText.setEnabled(false);
            jenisHelmCmbBox1.setEnabled(true);
            jenisHelmCmbBox2.setEnabled(true);
            jenisHelmCmbBox3.setEnabled(true);
            merkHelmText2.setEnabled(true);
            merkHelmText1.setEnabled(true);
            merkHelmText.setEnabled(true);
        } else {
            jenisHelmCmbBox1.setEnabled(false);
            jenisHelmCmbBox2.setEnabled(false);
            jenisHelmCmbBox3.setEnabled(false);
            merkHelmText2.setEnabled(false);
            merkHelmText1.setEnabled(false);
            merkHelmText.setEnabled(false);
        }
    }//GEN-LAST:event_jumlahHelmTextKeyReleased

    private void jenisHelmCmbBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jenisHelmCmbBox3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jenisHelmCmbBox3ActionPerformed

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        // TODO add your handling code here:
        DataParkir data_Parkir = new DataParkir();
        String merk1 = merkHelmText.getText();
        String merk2 = merkHelmText1.getText();
        String merk3 = merkHelmText2.getText();
        String jumHelm = jumlahHelmText.getText();
        if ((merkHelmText.isEnabled() && merk1.matches(""))
                || (merkHelmText1.isEnabled() && merk2.matches(""))
                || (merkHelmText2.isEnabled() && merk3.matches(""))) {
            JOptionPane.showMessageDialog(rootPane, "Merk helm belum diisi");
        } else {
            try {
                data_Parkir.setNoParkir(idParkirTextField.getText());
                data_Parkir.setIdKaryawan(nipUserLabel.getText());
                data_Parkir.setKode_karesidenan(kodeKaresidenanText.getText().toUpperCase());
                data_Parkir.setNo_polisi(noKendaraanText.getText());
                data_Parkir.setKode_wilayah(kodeWilayahText.getText().toUpperCase());
                data_Parkir.setJamMasukShift(jamMasukKaryawan);

                String no_Polisi_Kendaraan = data_Parkir.getKode_karesidenan() + " " + data_Parkir.getNo_polisi() + " " + data_Parkir.getKode_wilayah();
                data_Parkir.setNoPolisiKendaraan(no_Polisi_Kendaraan.toUpperCase());

                data_Parkir.setJumlahHelm(Integer.parseInt(jumlahHelmText.getText()));
                if (jumlahHelmText.getText().matches("1")) {
                    data_Parkir.setMerkHelm(merkHelmText2.getText());

                    String kode_Merk_Jenis = merkHelmText2.getText() + " - " + jenisHelmCmbBox1.getSelectedItem().toString();
                    data_Parkir.setKode_merkHelm_jenisHelm(kode_Merk_Jenis);
                } else if (jumlahHelmText.getText().matches("2")) {
                    data_Parkir.setMerkHelm(merkHelmText2.getText());
                    data_Parkir.setMerkHelm(merkHelmText1.getText());

                    String kode_Merk_Jenis = merkHelmText2.getText() + " - " + jenisHelmCmbBox1.getSelectedItem().toString()
                            + ", " + merkHelmText1.getText() + " - " + jenisHelmCmbBox2.getSelectedItem().toString();
                    data_Parkir.setKode_merkHelm_jenisHelm(kode_Merk_Jenis);
                } else if (jumlahHelmText.getText().matches("3")) {
                    data_Parkir.setMerkHelm(merkHelmText2.getText());
                    data_Parkir.setMerkHelm(merkHelmText1.getText());
                    data_Parkir.setMerkHelm(merkHelmText.getText());

                    String kode_Merk_Jenis = merkHelmText2.getText() + " - " + jenisHelmCmbBox1.getSelectedItem().toString()
                            + ", " + merkHelmText1.getText() + " - " + jenisHelmCmbBox2.getSelectedItem().toString()
                            + ", " + merkHelmText.getText() + " - " + jenisHelmCmbBox3.getSelectedItem().toString();
                    data_Parkir.setKode_merkHelm_jenisHelm(kode_Merk_Jenis.toUpperCase());
                } else if (jumlahHelmText.getText().matches("0")){
                    String kode_Merk_Jenis =  " - ";
                    data_Parkir.setKode_merkHelm_jenisHelm(kode_Merk_Jenis.toUpperCase());
                }

                GregorianCalendar tanggal_Masuk = new GregorianCalendar();

                SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
                String date1 = dateFormat.format(tanggal_Masuk.getTime());
                data_Parkir.setTanggalMasuk(date1);

                SimpleDateFormat dateFormat2 = new SimpleDateFormat("hh:mm:ss");
                String time = dateFormat2.format(tanggal_Masuk.getTime());
                data_Parkir.setJamMasuk(time);

                DataParkir.getConnection().simpanDataParkir(data_Parkir);

                TransaksiParkirController.cetakLaporan(data_Parkir);
                TransaksiParkirController.noParkir(idParkirTextField);

                jenisHelmCmbBox1.setEnabled(false);
                jenisHelmCmbBox2.setEnabled(false);
                jenisHelmCmbBox3.setEnabled(false);
                merkHelmText2.setEnabled(false);
                merkHelmText1.setEnabled(false);
                merkHelmText.setEnabled(false);
                jumlahHelmText.setText(null);
                kodeKaresidenanText.setText(null);
                kodeWilayahText.setText(null);
                noKendaraanText.setText(null);
                merkHelmText.setText(null);
                merkHelmText1.setText(null);
                merkHelmText2.setText(null);

            } catch (NumberFormatException ex) {
                JOptionPane.showMessageDialog(null, "Format input jumlah helm salah, input harus berupa angka 0-3");
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e.getMessage());
            }
        }
    }//GEN-LAST:event_okButtonActionPerformed

    private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed
        // TODO add your handling code here:
        try {
            DataParkir.getConnection().deleteDataParkir(idParkirTextField.getText().substring(0, 5));
            String jamMasuk = this.jamMasukKaryawan;
            TransaksiParkirController.openRekap(this, jamMasuk);
        } catch (IOException ex) {
            Logger.getLogger(LayananMasukForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(LayananMasukForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_logoutButtonActionPerformed

    private void back_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_back_ButtonActionPerformed
        try {
            // TODO add your handling code here:
            DataParkir.getConnection().deleteDataParkir(idParkirTextField.getText().substring(0, 5));
            TransaksiParkirController.openMainForm(this);
        } catch (SQLException ex) {
            Logger.getLogger(LayananMasukForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(LayananMasukForm.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_back_ButtonActionPerformed

    private void kodeKaresidenanTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_kodeKaresidenanTextKeyReleased
        // TODO add your handling code here:
        if (kodeKaresidenanText.getText().toCharArray().length == 2) {
            noKendaraanText.requestFocus();
        }
    }//GEN-LAST:event_kodeKaresidenanTextKeyReleased

    private void noKendaraanTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_noKendaraanTextKeyReleased
        // TODO add your handling code here:
        if (noKendaraanText.getText().startsWith("0")) {
            JOptionPane.showMessageDialog(rootPane, "Nomor polisi tidak diawali dengan angka 0");
        }
        if (noKendaraanText.getText().toCharArray().length == 4) {
            kodeWilayahText.requestFocus();
        }
    }//GEN-LAST:event_noKendaraanTextKeyReleased

    private void kodeWilayahTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_kodeWilayahTextKeyReleased
        // TODO add your handling code here:
        if (kodeWilayahText.getText().toCharArray().length == 3) {
            jumlahHelmText.requestFocus();
        }
    }//GEN-LAST:event_kodeWilayahTextKeyReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton back_Button;
    private javax.swing.JButton cancelButton;
    private javax.swing.JLabel dateLabel;
    private javax.swing.JLabel idParkirLabel;
    private javax.swing.JTextField idParkirTextField;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel jabatanLabel;
    private javax.swing.JLabel jamMasukShift;
    private javax.swing.JComboBox jenisHelmCmbBox1;
    private javax.swing.JComboBox jenisHelmCmbBox2;
    private javax.swing.JComboBox jenisHelmCmbBox3;
    private javax.swing.JLabel jenisHelmLabel;
    private javax.swing.JLabel jumlahHelmLabel;
    private javax.swing.JTextField jumlahHelmText;
    private javax.swing.JTextField kodeKaresidenanText;
    private javax.swing.JTextField kodeWilayahText;
    private javax.swing.JLabel label_Jam_Masuk;
    private javax.swing.JButton logoutButton;
    private javax.swing.JLabel merkHelmLabel;
    private javax.swing.JTextField merkHelmText;
    private javax.swing.JTextField merkHelmText1;
    private javax.swing.JTextField merkHelmText2;
    public javax.swing.JLabel nameUserLabel;
    public javax.swing.JLabel nipUserLabel;
    private javax.swing.JTextField noKendaraanText;
    private javax.swing.JLabel noPolisiLabel;
    private javax.swing.JButton okButton;
    private javax.swing.JLabel userLabel;
    // End of variables declaration//GEN-END:variables
}
